package com.ithrima.activiti.day04;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;

import java.util.HashMap;
import java.util.Map;

/**
 *  启动流程实例，动态设置assignee
 */
public class AssigneeUEL {
    public static void main(String[] args) {
        //1. 得到processEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2. 得到RunService对象
        RuntimeService runtimeService = processEngine.getRuntimeService();
        //3. 设置assignee取值   用户可以在页面上设置流程的执行人
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("assignee","zhangsan");
        objectObjectHashMap.put("assignee2","lisi");
        objectObjectHashMap.put("assignee3","wangwu");
        //4 启动流程设置，任务的审核人
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("helloword",objectObjectHashMap);
        //4. 输出实例相关的信息
        System.out.println("流程部署的ID"+processInstance.getDeploymentId());
        System.out.println("部署流程ID"+processInstance.getProcessDefinitionId());
        System.out.println("流程实例的ID"+processInstance.getId());
        System.out.println("活动的ID"+processInstance.getActivityId());
    }



}
